<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="lib/axios.js"></script>
  </head>
  <body>
    <button id="btn1">直接发起axios(GET)请求</button>
    <button id="btn2">直接发起axios(POST)请求</button>
    <script>
      document.querySelector("#btn1").addEventListener("click", function () {
        // 请求的url地址
        let url = "http:www.liulongbin.top:3006/api/get";
        // 请求的参数对象
        let paramsObj = { name: "zs", age: 20 };
        // axios({
        //   method: "GET",
        //   url: url,
        //   params: paramsObj,
        // }).then(function (res) {
        //   console.log(res.data);
        // });
        axios({
          method: "GET",
          url: "http:www.liulongbin.top:3006/api/get",
          pramas: {
            name: "zs",
            age: 20,
          },
        }).then((res) => {
          console.log(res.data);
        });
      });
      document.querySelector("#btn2").addEventListener("click", function () {
        axios({
          method: "POST",
          url: "http:www.liulongbin.top:3006/api/post",
          data: {
            name: "assda",
            age: 18,
          },
        }).then(function (res) {
          console.log(res.data);
        });
      });
    </script>
  </body>
</html>
